package com.hmall.api.client.fallback;


import com.hmall.api.client.UserClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;

/**
 * 自定义FallbackFactory
 */
@Slf4j
public class UserClientFallbackFactory implements FallbackFactory<UserClient> {
    /**
     * 调用失败后的后备解决方案
     * @param cause
     * @return
     */
    @Override
    public UserClient create(Throwable cause) {
        return new UserClient() {
            @Override
            public void deductMoney(String pw, Integer amount) {
                throw new RuntimeException(cause);
            }
        };
    }
}
